/*
	需要统计的广告需要添加 adStatistics 类名。
*/

var cliC = {
	init:function(element) {
		var _this = this,
			ele   = (element || document).getElementsByTagName('*');
		for(var i=0,l=ele.length;i<l;i++) {
			_this.addHandler(ele,"click",_this.cRun);
		}
	},
	cRun:function(e) {
		var e  = e || window.event,
			ea = e.srcElement || e.target,
			ad = ea.className.indexOf("adStatistics")!=-1?true:false;
			if(ad) cliC.creat();
	},
	creat:function() {
		if(document.getElementById("adHitsad")) document.body.removeChild(document.getElementById("adHitsad"));
		var script = document.creatElement("script");
		script.src = "../../../../../interactive.huanqiu.com/-c=hitsad&a=addHitsad&callback=cliC.getData"/*tpa=http://interactive.huanqiu.com/?c=hitsad&a=addHitsad&callback=cliC.getData*/;
		script.id  = "adHitsad";
		document.body.appendChild(script);
	},
	getData:function(data) {
	   if(!data.code) setTimeout(cliC.creat,500);
	},
	addHandler:function(element,type,handler) { 
		if(element.addEventListener) {
			element.addEventListener(type,handler,false);
		}else if(element.attachEvent){
			element.attachEvent('on'+type,handler);
		}else {
			element['on'+type] = handler;
		}
	}
};
cliC.init();